from django.shortcuts import render
import re

from django.contrib.auth import login
from django.http import HttpResponseBadRequest,HttpResponse
from django import http
from django.shortcuts import render, redirect
from django_redis import get_redis_connection

from django.views import View

from contents.models import ContentCategory
from goods.models import GoodsChannel
from qingmei_mall.utils import get_category
from qingmei_mall.utils.response_code import  RETCODE

from users.models import User

# Create your views here.

class Frirst_View(View):

    def get(self,request):
        categorie=get_category.get_category()


         # 获取广告类别信息
        conten_categories = ContentCategory.objects.all()

        content_dict = {}
        for content in conten_categories:
            content_dict[content.key] = content.content_set.filter(status=True).order_by('sequence')

        context = {'categories': categorie,
                   'contents': content_dict}
        # print(categorie[1]['sub_cats'])
        return render(request,'index.html',context)
 #
 # 'category': [channle.category.name],
 #        'url': [channle.url]